import { User } from '@boticord/users-client'
import { Column, Entity, JoinTable, ManyToOne, OneToMany } from 'typeorm'
import { Resource } from './resource.model'
import { DiscordID } from '@boticord/common'
import { Report } from '@boticord/resources-client/models/report.model'

@Entity()
export class ResourceComment extends DiscordID {
  @ManyToOne(() => User, u => u.comments)
  declare author: User

  @Column({ nullable: true, default: null })
  declare content?: string

  // rating of resource in which comment was made
  @Column()
  declare rating: number

  @ManyToOne(() => Resource, r => r.comments)
  declare resource: Resource

  @OneToMany(() => Report, r => r.resource)
  @JoinTable()
  declare reports: Report[]

  @Column({ default: null })
  declare modReply?: string

  @Column('timestamp with time zone', { nullable: false, default: () => 'CURRENT_TIMESTAMP' })
  declare createdDate: Date
}
